﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Classified.Data.Infrastructure;
using Classified.Domain.Entities;

namespace Classified.Data.Repositories
{

    public class MessageInfoRepositories : RepositoryBase<MessageInfo>, IMessageInfoRepositories
    {

        public MessageInfoRepositories(IDatabaseFactory databaseFactory)
            : base(databaseFactory)
        {
        }
        public static int GetNewMessageByUserId(int userId)
        {
            var _context = new ClassifiedContext();
            var msg =
                _context.MessageInfos.Where(x => x.UserId == userId && x.IsRead == false).OrderByDescending(
                    x => x.SentDate).Count();
            return msg;
        }
    }
    public interface IMessageInfoRepositories : IRepository<MessageInfo>
    {

       
    }
}
